﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    Theme="SkinFile" Inherits="Nivdal.Friendly" CodeBehind="Friendly.aspx.cs" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ID="HeadContent" runat="server" ContentPlaceHolderID="HeadPlaceHolder">
    <script language="javascript" type="text/javascript">
        function ShowDetails() {
            $("#ctl00_ctl00_ContentPlaceHolder3_ContentPlaceHolder1_ShowDetailsLinkButton").hide();
            $("#Detailsdiv").show(200);     
        }

        function HideDetails() {
            $("#ctl00_ctl00_ContentPlaceHolder3_ContentPlaceHolder1_ShowDetailsLinkButton").show();
            $("#Detailsdiv").hide();
        }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    
    <asp:UpdatePanel ID="MessageUpdatePanel" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Panel ID="MessagePanel" runat="server">
                <div class="basic_element">
                    <asp:Label ID="MessageLabel" runat="server" SkinID="GreenSmallHeaderLabel"></asp:Label>
                </div>
            </asp:Panel>  
        </ContentTemplate>
    </asp:UpdatePanel>
    
    <asp:UpdatePanel ID="FriendlyPoolUpdatePanel" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        
        <asp:UpdateProgress ID="UpdateProgress2" AssociatedUpdatePanelID="FriendlyPoolUpdatePanel" runat="server">
            <ProgressTemplate>
                <div class="ajaxloader">
                    <asp:Image ID="MessageUpdateProgress" runat="server" ImageUrl="~/Images/ajax-loader.gif"/>
                </div> 
            </ProgressTemplate>
        </asp:UpdateProgress>
           
        <asp:Panel ID="JoinFriendlyPoolPanel" runat="server">
            <div class="basic_element">
            <div class="red_title">
                <asp:Label ID="JoinThePoolTitleLabel" runat="server" CssClass="white_title" Text="<%$ Resources:Resource, Friendly_JoinFriendlyPoolLabel %>"></asp:Label>            
            </div>
            <div class="padding5">
            <div id="Detailsdiv">
                <table cellpadding="3" cellspacing="0">
                <tr>
                <td>
                    <asp:Label ID="VenueTitleLabel" runat="server" Text="<%$ Resources:Resource, Friendly_VenueTitleLabel %>" SkinID="InfoLabel"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="VenueDDL" runat="server" Width="179">
                        <asp:ListItem Value="1" Text="<%$ Resources:Resource, Friendly_VenueHome %>"></asp:ListItem>
                        <asp:ListItem Value="2" Text="<%$ Resources:Resource, Friendly_VenueAway %>"></asp:ListItem>
                        <asp:ListItem Value="3" Text="<%$ Resources:Resource, Friendly_DontCare %>" Selected="True"></asp:ListItem>
                    </asp:DropDownList>
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="InternationalTitleLabel" runat="server" Text="<%$ Resources:Resource, Friendly_InternationalTitleLabel %>" SkinID="InfoLabel"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="InternationalDDL" runat="server" Width="179">
                        <asp:ListItem Value="1" Text="<%$ Resources:Resource, Friendly_National %>"></asp:ListItem>
                        <asp:ListItem Value="2" Text="<%$ Resources:Resource, Friendly_International %>"></asp:ListItem>                        
                        <asp:ListItem Value="3" Text="<%$ Resources:Resource, Friendly_DontCare %>" Selected="True"></asp:ListItem>
                    </asp:DropDownList>
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="GameRulesTitleLabel" runat="server" Text="<%$ Resources:Resource, Friendly_GameRulesTitleLabel %>" SkinID="InfoLabel"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="GameRulesDDL" runat="server" Width="179">
                        <asp:ListItem Value="1" Text="<%$ Resources:Resource, Friendly_GameRulesRegular %>"></asp:ListItem>
                        <asp:ListItem Value="2" Text="<%$ Resources:Resource, Friendly_GameRulesCup %>"></asp:ListItem>
                        <asp:ListItem Value="3" Text="<%$ Resources:Resource, Friendly_DontCare %>" Selected="True"></asp:ListItem>
                    </asp:DropDownList>
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="LeagueLevelTitleLabel" runat="server" Text="<%$ Resources:Resource, Friendly_LeagueLevelTitleLabel %>" SkinID="InfoLabel"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="LeaguesDDL" runat="server" Width="179">
                        <asp:ListItem Value="0" Text="<%$ Resources:Resource, Friendly_DontCare %>" Selected="True"></asp:ListItem>
                    </asp:DropDownList>
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="StartDateTitleLabel" runat="server" Text="<%$ Resources:Resource, Friendly_StartDateTitle %>" SkinID="InfoLabel"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="StartDateTextBox" runat="server" Width="80"></asp:TextBox>
                    <cc1:CalendarExtender ID="StartDateCalendarExtender" runat="server" Animated="true" Format="dd/MM/yyyy" 
                    TargetControlID="StartDateTextBox" PopupPosition="BottomRight"  CssClass="NivdalCalendar"></cc1:CalendarExtender>
                    <asp:DropDownList ID="StartDateHoursDDL" runat="server">
                        <asp:ListItem Selected="True" Value="00" Text="00"></asp:ListItem>
                        <asp:ListItem Value="01" Text="01"></asp:ListItem>
                        <asp:ListItem Value="02" Text="02"></asp:ListItem>
                        <asp:ListItem Value="03" Text="03"></asp:ListItem>
                        <asp:ListItem Value="04" Text="04"></asp:ListItem>
                        <asp:ListItem Value="05" Text="05"></asp:ListItem>
                        <asp:ListItem Value="06" Text="06"></asp:ListItem>
                        <asp:ListItem Value="07" Text="07"></asp:ListItem>
                        <asp:ListItem Value="08" Text="08"></asp:ListItem>
                        <asp:ListItem Value="09" Text="09"></asp:ListItem>
                        <asp:ListItem Value="10" Text="10"></asp:ListItem>
                        <asp:ListItem Value="11" Text="11"></asp:ListItem>
                        <asp:ListItem Value="12" Text="12"></asp:ListItem>
                        <asp:ListItem Value="13" Text="13"></asp:ListItem>
                        <asp:ListItem Value="14" Text="14"></asp:ListItem>
                        <asp:ListItem Value="15" Text="15"></asp:ListItem>
                        <asp:ListItem Value="16" Text="16"></asp:ListItem>
                        <asp:ListItem Value="17" Text="17"></asp:ListItem>
                        <asp:ListItem Value="18" Text="18"></asp:ListItem>
                        <asp:ListItem Value="19" Text="19"></asp:ListItem>
                        <asp:ListItem Value="20" Text="20"></asp:ListItem>
                        <asp:ListItem Value="21" Text="21"></asp:ListItem>
                        <asp:ListItem Value="22" Text="22"></asp:ListItem>
                        <asp:ListItem Value="23" Text="23"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:Label ID="StartDateDotsLabel" runat="server" Text=":"></asp:Label>
                    <asp:DropDownList ID="StartTimeMinutesDDL" runat="server">
                        <asp:ListItem Selected="True" Text="00" Value="00"></asp:ListItem>
                        <asp:ListItem Text="15" Value="15"></asp:ListItem>
                        <asp:ListItem Text="30" Value="30"></asp:ListItem>
                        <asp:ListItem Text="45" Value="45"></asp:ListItem>
                    </asp:DropDownList>
                    
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="EndDate" runat="server" Text="<%$ Resources:Resource, Friendly_EndDateTitle %>" SkinID="InfoLabel"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="EndDateTextBox" runat="server" Width="80"></asp:TextBox>
                    <cc1:CalendarExtender ID="EndDateCalendarExtender" runat="server" Animated="true" CssClass="NivdalCalendar"
                    TargetControlID="EndDateTextBox" PopupPosition="BottomRight" Format="dd/MM/yyyy" TodaysDateFormat="dd/MM/yyyy"  ></cc1:CalendarExtender>
                    <asp:DropDownList ID="EndDateHoursDDL" runat="server">
                        <asp:ListItem Selected="True" Value="00" Text="00"></asp:ListItem>
                        <asp:ListItem Value="01" Text="01"></asp:ListItem>
                        <asp:ListItem Value="02" Text="02"></asp:ListItem>
                        <asp:ListItem Value="03" Text="03"></asp:ListItem>
                        <asp:ListItem Value="04" Text="04"></asp:ListItem>
                        <asp:ListItem Value="05" Text="05"></asp:ListItem>
                        <asp:ListItem Value="06" Text="06"></asp:ListItem>
                        <asp:ListItem Value="07" Text="07"></asp:ListItem>
                        <asp:ListItem Value="08" Text="08"></asp:ListItem>
                        <asp:ListItem Value="09" Text="09"></asp:ListItem>
                        <asp:ListItem Value="10" Text="10"></asp:ListItem>
                        <asp:ListItem Value="11" Text="11"></asp:ListItem>
                        <asp:ListItem Value="12" Text="12"></asp:ListItem>
                        <asp:ListItem Value="13" Text="13"></asp:ListItem>
                        <asp:ListItem Value="14" Text="14"></asp:ListItem>
                        <asp:ListItem Value="15" Text="15"></asp:ListItem>
                        <asp:ListItem Value="16" Text="16"></asp:ListItem>
                        <asp:ListItem Value="17" Text="17"></asp:ListItem>
                        <asp:ListItem Value="18" Text="18"></asp:ListItem>
                        <asp:ListItem Value="19" Text="19"></asp:ListItem>
                        <asp:ListItem Value="20" Text="20"></asp:ListItem>
                        <asp:ListItem Value="21" Text="21"></asp:ListItem>
                        <asp:ListItem Value="22" Text="22"></asp:ListItem>
                        <asp:ListItem Value="23" Text="23"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:Label ID="DotsLabel2" runat="server" Text=":"></asp:Label>
                    <asp:DropDownList ID="EndTimeMinutesDDL" runat="server">
                        <asp:ListItem Selected="True" Text="00" Value="00"></asp:ListItem>
                        <asp:ListItem Text="15" Value="15"></asp:ListItem>
                        <asp:ListItem Text="30" Value="30"></asp:ListItem>
                        <asp:ListItem Text="45" Value="45"></asp:ListItem>
                    </asp:DropDownList>
                </td>                
                </tr>
                <%--<tr>
                <td>
                    <asp:LinkButton ID="CloseDetailsLinkButton" runat="server" OnClientClick="HideDetails(); return false;"
                     SkinID="GreenTitleLink" Text="<%$ Resources:Resource, Friendly_HideDetailsText %>"></asp:LinkButton>
                </td>
                </tr>--%>
                </table>
            </div>
            <br />
            <asp:Button ID="JoinPoolButton" runat="server" Text="<%$ Resources:Resource, Friendly_JoinButtonText %>" OnClick="JoinFrienldyPool"
             CssClass="GreenSmallButtonStyle" />
            
            </div></div>
        </asp:Panel>
        <asp:Panel ID="JoinedFriendlyPoolPanel" runat="server">
            <div class="basic_element">
            <div class="red_title">
                <asp:Label ID="JoinedFriendlyPoolLabel" runat="server" Text="<%$ Resources:Resource, Friendly_JoinedFriendlyPool %>" CssClass="white_title"></asp:Label>
            
            </div>
            <div class="padding5">
            
            <asp:FormView ID="JoinedFriendlyPoolFormView" runat="server" DataSourceID="JoinedFriendlyPoolDataSource">
            <ItemTemplate>
                <table cellpadding="5">
                <tr>
                <td>
                    <asp:Label ID="MatchInstructionsLabel" runat="server" Text='<%# InstructionsToolTip(Eval("InstructionsNeeded")) %>' SkinID="GridLabel"></asp:Label>
                </td>
                <td>
                    <asp:HyperLink ID="MatchInstructionsHyperlink" runat="server"
                     ImageUrl='<%# InstructionsImage(Eval("InstructionsNeeded")) %>' 
                     ToolTip='<%# InstructionsToolTip(Eval("InstructionsNeeded")) %>'
                     NavigateUrl='<%# "~/MatchInstructions_New.aspx?MatchId=" + Eval("MatchId") %>'></asp:HyperLink>
                </td>
                </tr>
                <tr>
                <td>
                     <asp:HiddenField ID="MatchIdHiddenField" runat="server" Value='<%# Eval("MatchId") %>' />
                     <asp:Label ID="StadiumTitleLabel" runat="server" Text="<%$ Resources:Resource, Global_AssignStadium %>" SkinID="GridLabel"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="StadiumsDDL" runat="server" DataSourceID="StadiumsDDLDataSource" DataTextField="StadiumName" 
                    DataValueField="StadiumId" SelectedValue='<%# Eval("StadiumId") %>'></asp:DropDownList>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ValidationGroup="AssignStadium"
                    ControlToValidate="StadiumsDDL" SetFocusOnError="true"></asp:RequiredFieldValidator>
                    <asp:ImageButton ID="AssignStadiumImageButton" runat="server" ImageUrl="~/Images/Icons/vi.png" OnClick="AssignStadium"
                    CausesValidation="true" ValidationGroup="AssignStadium" />
                </td>
                </tr>
                <tr>
                <td colspan="2">
                    <asp:Button ID="LeavePoolButton" runat="server" Text="<%$ Resources:Resource, Friendly_LeaveFriendlyPool %>" 
                    OnClick="LeaveFriendlyPool" CssClass="GreenSmallButtonStyle" />
                </td>
                </tr>
                </table>                
            </ItemTemplate>
            </asp:FormView>
            <asp:SqlDataSource ID="JoinedFriendlyPoolDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                SelectCommand="Nivdal_FriendlyPoolGetTeamInfo" SelectCommandType="StoredProcedure">
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="StadiumsDDLDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                SelectCommand="Nivdal_GetStadiumsDDLForMatch" SelectCommandType="StoredProcedure">
            </asp:SqlDataSource>
            
            </div>
            </div>
            
        </asp:Panel>
        <asp:Panel ID="ExistingSuggestionsPanel" runat="server">
            <div class="basic_element">
            <div class="red_title">
                <asp:Label ID="ExistingSuggestionsTitleLabel" runat="server" Text="<%$ Resources:Resource, Friendly_ExistingSuggestions %>" CssClass="white_title"></asp:Label>
            </div>
            <div class="padding5">
            <asp:GridView ID="ExistingSuggestionsGridview" runat="server" SkinID="Professional" DataSourceID="ExistingFriendlyPoolSuggestions"
             AllowPaging="true" PageSize="10" AutoGenerateColumns="false" OnRowCommand="AcceptFriendlyPoolSuggestion">
                <PagerSettings FirstPageText="<%$ Resources:Resource, FirstPage %>" LastPageText="<%$ Resources:Resource, LastPage %>"
                 Mode="NumericFirstLast" PageButtonCount="10" Position="Bottom" />
                <PagerStyle CssClass="pagination" HorizontalAlign="Center" />
                <Columns>
                    <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_Team %>">
                        <ItemTemplate>
                            &nbsp;
                            <asp:Image ID="FlagImage" runat="server" ImageUrl='<%# "~/Images/Flags/" + Eval("FlagImage") %>' ToolTip='<%# Eval("CountryName") %>' />
                            &nbsp;
                            <asp:HyperLink ID="TeamIdHyperlink" runat="server" NavigateUrl='<%# "~/TeamHomePage.aspx?TeamId=" + Eval("TeamId")  %>'
                             Text='<%# Eval("TeamName") %>' SkinID="BlackHyperLinkSkin"></asp:HyperLink>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_Time %>">
                        <ItemTemplate>
                            <asp:Label ID="MatchTimeLabel" runat="server" Text='<%# Eval("MatchTime") %>' SkinID="GridLabel"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="<%$ Resources:Resource, Friendly_OtherConditions %>">
                        <ItemTemplate>
                            <table>
                            <tr>
                            <td>
                                <asp:Label ID="VenueTitleLabel" runat="server" Text="<%$ Resources:Resource, Friendly_VenueTitleLabel %>" SkinID="InfoLabel"></asp:Label>
                            </td>
                            <td>
                                <asp:Label ID="VenueLabel" runat="server" Text='<%# VenueString(Eval("Venue")) %>' SkinID="GridLabel"></asp:Label>
                            </td>
                            </tr>
                            <tr>
                            <td>
                                <asp:Label ID="GameRulesTitleLabel" runat="server" Text="<%$ Resources:Resource, Friendly_GameRulesTitleLabel %>" SkinID="InfoLabel"></asp:Label>
                            </td>
                            <td>
                                <asp:Label ID="GameRulesLabel" runat="server" Text='<%# RulesString(Eval("GameRules")) %>' SkinID="GridLabel" ></asp:Label>
                            </td>
                            </tr>
                            </table>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:LinkButton ID="AcceptLinkButton" runat="server" CommandName="Accept" CommandArgument='<%# Eval("PoolId") %>'
                             SkinID="GreenTitleLink" Text="<%$ Resources:Resource, Friendly_PlayTheMatchText %>" Visible='<%# Eval("Fits") %>'></asp:LinkButton>
                            <asp:Label ID="CannotPlaylabel" runat="server" Text="<%$ Resources:Resource, Friendly_CannotPlay %>"
                            Visible='<%# !(bool)Eval("Fits") %>' SkinID="GridLabel"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="ExistingFriendlyPoolSuggestions" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                SelectCommand="Nivdal_FriendlyPoolGetAllTeamsInPool" SelectCommandType="StoredProcedure">
            </asp:SqlDataSource>
            </div></div>
        </asp:Panel>
    </ContentTemplate>
    </asp:UpdatePanel>
    
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
        <div class="ajaxloader">
            <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/ajax-loader.gif" />
        </div>
        </ProgressTemplate>
        </asp:UpdateProgress>
        
        
        <asp:HiddenField ID="TeamIdHiddenField" runat="server" />
        <asp:Panel ID="IncomingChallangesPanel" runat="server">
            <div class="basic_element">
            <div class="red_title">
                <asp:Label ID="IncomingChallangesTitleLabel" runat="server" CssClass="white_title" Text="<%$ Resources:Resource, Friendly_IncomingChallangesTitleLabelText %>"></asp:Label>
            </div>
            <div class="padding5">
            
            <asp:GridView ID="IncomingChallangesGridView" runat="server" DataSourceID="ChallangesDataSourse"
                SkinID="Professional" AutoGenerateColumns="false"  AllowPaging="true"
                PageSize="13" OnRowCommand="IncomingFriendlyRowCommand">
                <%--<EmptyDataTemplate>
                    <asp:Label ID="NoIncomingChallangesLabel" runat="server" SkinID="GridLabel" Text="<%$ Resources:Resource, Friendly_NoIncomingChallangesLabelText %>"></asp:Label>
                </EmptyDataTemplate>--%>
                <PagerSettings FirstPageText="<%$ Resources:Resource, FirstPage %>" LastPageText="<%$ Resources:Resource, LastPage %>"
                        Mode="NumericFirstLast" PageButtonCount="10" Position="Bottom" />
                    <PagerStyle CssClass="pagination" HorizontalAlign="Center" />
                <Columns>
                    <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_Date %>" ItemStyle-Width="25%">
                        <ItemTemplate>
                            <asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date") %>' SkinID="GridLabel"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_From %>" ItemStyle-Width="45%">
                        <ItemTemplate>
                            <asp:HyperLink ID="ToTeamHyperlink" runat="server" SkinID="BlackHyperLinkSkin" NavigateUrl='<%# "~/TeamHomePage.aspx?TeamId=" + Eval("TeamId") %>'
                                Text='<%# Eval("TeamName") %>'></asp:HyperLink>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ItemStyle-Width="10%">
                        <ItemTemplate>
                            <asp:Label ID="HomeMatchLabel" runat="server" Text="<%$ Resources:Resource, Friendly_HomeMatch %>"
                             SkinID="GridLabel" Visible='<%# !(bool)Eval("SuggestingTeamHosts") %>'></asp:Label>
                            <asp:Label ID="AwayMatchLabel" runat="server" Text="<%$ Resources:Resource, Friendly_AwayMatch %>"
                             SkinID="GridLabel" Visible='<%# Eval("SuggestingTeamHosts") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ItemStyle-Width="10%">
                        <ItemTemplate>
                            <asp:Label ID="NormalRulesLabel" runat="server" Text="<%$ Resources:Resource, Friendly_NormalRules %>"
                             SkinID="GridLabel" Visible='<%# !(bool)Eval("CupRules") %>'></asp:Label>
                            <asp:Label ID="CupRulesLabel" runat="server" Text="<%$ Resources:Resource, Friendly_CupRules %>"
                             SkinID="GridLabel" Visible='<%# Eval("CupRules") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ItemStyle-Width="10%">
                        <ItemTemplate>
                            <asp:ImageButton ID="AcceptFriendlyImageButton" runat="server" ImageUrl="~/Images/Icons/vi.png"
                                ToolTip="<%$ Resources:Resource, Friendly_AcceptFriendlyToolTip %>" CommandName="Accept"
                                CommandArgument='<%# Eval("Id") %>' OnClientClick='<%# AcceptChallangeOnClientClick((string)Eval("TeamName")) %>' />
                            <asp:ImageButton ID="DeclineFriendlyImageButton" runat="server" ImageUrl="~/Images/Icons/delete.png"
                                ToolTip="<%$ Resources:Resource, Friendly_DeclineFriendlyToolTip %>" CommandName="Decline"
                                CommandArgument='<%# Eval("Id") %>' OnClientClick='<%# DeclineChallangeOnClientClick((string)Eval("TeamName")) %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            
            </div>
            </div>
        </asp:Panel>
        <asp:Panel ID="OutgoingChallangesPanel" runat="server">
            <div class="basic_element">
            <div class="red_title">
            <asp:Label ID="OutgoingChallangesTitleLabel" runat="server" CssClass="white_title" Text="<%$ Resources:Resource, Friendly_OutgoingChallangesTitleLabelText %>"></asp:Label>
            </div>
            <div class="padding5">
            <asp:GridView ID="OutgoingFriendlyChallangesGridView" runat="server" SkinID="Professional"
                DataSourceID="SuggestionsDataSourse" AllowPaging="true" PageSize="13" AutoGenerateColumns="false"
                OnRowCommand="WithdrawFriendly">
                <%--<EmptyDataTemplate>
                    <asp:Label ID="NoOutgoingChallanges" runat="server" Text="<%$ Resources:Resource, Friendly_NoOutgoingChallangesLabelText %>"
                        SkinID="GridLabel"></asp:Label>
                </EmptyDataTemplate>--%>
                <PagerSettings FirstPageText="<%$ Resources:Resource, FirstPage %>" LastPageText="<%$ Resources:Resource, LastPage %>"
                    Mode="NumericFirstLast" PageButtonCount="10" Position="Bottom" />
                <PagerStyle CssClass="pagination" HorizontalAlign="Center" />
                <Columns>
                    <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_Date %>" ItemStyle-Width="25%">
                        <ItemTemplate>
                            <asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date") %>' SkinID="GridLabel"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="<%$ Resources:Resource, Follow_TransferToHeaderTextText %>" ItemStyle-Width="45%">
                        <ItemTemplate>
                            <asp:HyperLink ID="ChallangedTeamHyperlink" runat="server" SkinID="BlackHyperLinkSkin"
                                NavigateUrl='<%# "~/TeamHomePage.aspx?TeamId=" + Eval("TeamId") %>' Text='<%# Eval("TeamName") %>'></asp:HyperLink>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ItemStyle-Width="10%">
                        <ItemTemplate>
                            <asp:Label ID="HomeMatchLabel" runat="server" Text="<%$ Resources:Resource, Friendly_HomeMatch %>"
                             SkinID="GridLabel" Visible='<%# Eval("SuggestingTeamHosts") %>'></asp:Label>
                            <asp:Label ID="AwayMatchLabel" runat="server" Text="<%$ Resources:Resource, Friendly_AwayMatch %>"
                             SkinID="GridLabel" Visible='<%# !(bool)Eval("SuggestingTeamHosts") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ItemStyle-Width="10%">
                        <ItemTemplate>
                            <asp:Label ID="NormalRulesLabel" runat="server" Text="<%$ Resources:Resource, Friendly_NormalRules %>"
                             SkinID="GridLabel" Visible='<%# !(bool)Eval("CupRules") %>'></asp:Label>
                            <asp:Label ID="CupRulesLabel" runat="server" Text="<%$ Resources:Resource, Friendly_CupRules %>"
                             SkinID="GridLabel" Visible='<%# Eval("CupRules") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ItemStyle-Width="10%">
                        <ItemTemplate>
                            <asp:ImageButton ID="DeclineImageButton" runat="server" ImageUrl="~/Images/Icons/delete.png"
                                OnClientClick='<%# WithdrawChallangeOnClientClick((string)Eval("TeamName")) %>'
                                CommandArgument='<%# Eval("Id") %>' ToolTip="<%$ Resources:Resource, Friendly_WithdrawFriendlyToolTip %>" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            </div>
            </div>
        </asp:Panel>
        <div class="basic_element">
        <div class="red_title">
            <asp:Label ID="ScheduledMatchesTitleLabel" runat="server" CssClass="white_title" 
             Text="<%$ Resources:Resource, Friendly_FriendlyWeeksTitleLabel %>" ></asp:Label>
        </div>
        <div class="padding5">        
        <div style="width:50%;">
            <asp:GridView ID="FriendlyWeeksGridview" runat="server" SkinID="Professional" AllowPaging="false" 
            DataSourceId="FriendlyWeeksDataSource" AutoGenerateColumns="false">
            <Columns>
                <asp:TemplateField HeaderText="<%$ Resources:Resource, Friendly_FriendlyWeekTitle %>">
                    <ItemTemplate>
                        <asp:Label ID="DatesLabel" runat="server" Text='<%# Eval("FormattedStartDate") + " - " + Eval("FormattedEndDate") %>'
                         SkinID="GridLabel"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <HeaderTemplate>
                        <asp:Image ID="ScheduledMatchesHeaderImage" runat="server" ImageUrl="~/Images/Icons/Calendar.png"
                         ToolTip="<%$ Resources:Resource, Friendly_NumMatchesScheduled %>" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label ID="ScheduledMatchesLabel" runat="server" Text='<%# Eval("NumScheduledMatches") %>' SkinID="GridLabel"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <HeaderTemplate>
                        <asp:Image ID="CanScheduleHeaderImage" runat="server" ImageUrl="~/Images/Icons/Clock.png"
                         ToolTip="<%$ Resources:Resource, Friendly_NumMatchesCanBePlayed %>" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label ID="CanScheduleMatchedLabel" runat="server" Text='<%# Eval("NumMatches") %>' SkinID="GridLabel"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>  
                              
            </Columns>
            </asp:GridView>
        </div>
        <br /><br />
        <asp:HyperLink ID="AllTournamentsLink" runat="server" Text="<%$ Resources:Resource, AllTournaments_PageTitle %>"
        NavigateUrl="~/AllTournaments.aspx" SkinID="GreenTitleHyperLink"></asp:HyperLink>
        </div></div>
        <asp:Panel ID="ScheduledMatchesPanel" runat="server">
        <div class="basic_element">
        <div class="red_title">
        <asp:Label ID="ScheduledMatchesLabel" runat="server" CssClass="white_title" 
         Text="<%$ Resources:Resource, Friendly_ScheduledMatchesTitleLabelText %>"></asp:Label>
        </div>
        <div class="padding5">
        <asp:GridView ID="ScheduledMatchedGridvew" runat="server" DataSourceID="FriendlyGetAllTeamFriendlyMatchesDataSource" 
         SkinID="Professional" AllowPaging="false" AutoGenerateColumns="false" OnRowCommand="GamesGridViewRowCommand">
            <Columns>
                <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_Date %>" ItemStyle-Width="20%">
                    <ItemTemplate>
                        <asp:Label ID="DateLabel" runat="server" Text='<%# FormatMatchTime(Eval("MatchDate")) %>' SkinID="GridLabel"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ItemStyle-Width="4%" >
                    <ItemTemplate>
                        <asp:Image ID="MatchTypeImage" runat="server" ImageUrl='<%# GetNivdalData.GetNivdalData.GetIconByMatchType(Eval("Type")) %>' 
                         ToolTip='<%# GetNivdalData.GetNivdalData.GetToolTipByMatchType(Eval("Type")) %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="<%$ Resources:Resource, Global_Match %>" ItemStyle-Width="36%">
                    <ItemTemplate>
                        <asp:HyperLink ID="MatchHyperlink" runat="server" Text='<%# Eval("Title") %>'
                         SkinID="BlackHyperLinkSkin" NavigateUrl='<%# "~/MatchPage.aspx?MatchId=" + Eval("MatchId") %>'></asp:HyperLink>
                        <asp:Label ID="MatchTitleLabel" runat="server"  SkinID="GridLabel"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField  ItemStyle-Width="40%">
                    <ItemTemplate>
                        <asp:Panel ID="AgreeToDeletePanel" Visible='<%# Eval("CancelationStatus").ToString() == "4" %>' runat="server">
                            <asp:Label ID="OpponentSuggestedDeleteLable" runat="server" SkinID="GridLabel"
                            Text="<%$ Resources:Resource, Friendly_FriendlyDeleteSuggestedLabel %>"></asp:Label>
                            <br />
                            <asp:LinkButton ID="AcceptDeletion" runat="server" CommandArgument='<%# Eval("MatchId") %>' CommandName="AcceptCancel"
                             SkinID="GreenTitleLink" Text="<%$ Resources:Resource, Friendly_AcceptFriendlyCancelSuggestion %>"
                             message="<%$ Resources:Resource, Friendly_AreYouSureAcceptSuggestion %>"
                             OnClientClick='return confirm(this.getAttribute("message"))'></asp:LinkButton>
                             <asp:LinkButton ID="DeclineDeletion" runat="server" CommandArgument='<%# Eval("CancelSuggestionId") %>' CommandName="DeclineCancel"
                             SkinID="GreenTitleLink" Text="<%$ Resources:Resource, Friendly_DeclineFriendlyCancelSuggestion %>"
                             message="<%$ Resources:Resource, Friendly_AreYouSureDeclineSuggestion %>"
                             OnClientClick='return confirm(this.getAttribute("message"))'></asp:LinkButton>
                        </asp:Panel>
                        <asp:Panel ID="CancelPanel" runat="server" Visible='<%# Eval("CancelationStatus").ToString() == "2" %>'>
                            <asp:Label ID="CanSuggestLabel" runat="server" Text="<%$ Resources:Resource, Friendly_FriendlySuggestionCanBeSent %>"
                             SkinID="GridLabel"></asp:Label>
                            <asp:LinkButton ID="SuggestLinkButton" runat="server" Text="<%$ Resources:Resource, Friendly_SendCancelSuggestion %>"
                             SkinID="GreenTitleLink" CommandName="Suggest" CommandArgument='<%# Eval("MatchId") %>'
                             message="<%$ Resources:Resource, Friendly_AreYouSureSendSuggestion %>"
                             OnClientClick='return confirm(this.getAttribute("message"))'></asp:LinkButton>
                        </asp:Panel>
                        <asp:Panel ID="SuggestionSentPanel" runat="server" Visible='<%# Eval("CancelationStatus").ToString() == "3" %>'>
                            <asp:Label ID="SuggestionSentLabel" runat="server"  SkinID="GridLabel"
                            Text="<%$ Resources:Resource, Friendly_SuggestionSentText %>"></asp:Label>
                        </asp:Panel>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            
        </asp:GridView>
        </div></div>
        </asp:Panel>
        
    
    
    <asp:SqlDataSource ID="FriendlyWeeksDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="Nivdal_GetComingFriendlyWeeks" SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="ScheduledFriendlyGamesDataSourse" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="Nivdal_FriendlyGetScheduledFriendliesForUser" SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SuggestionsDataSourse" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="Nivdal_FriendlyGetSentSuggestionsForUser" SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>
    
    <asp:SqlDataSource ID="ChallangesDataSourse" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="Nivdal_FriendlyGetChallangesForUser" SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>
    
    <asp:SqlDataSource ID="FriendlyGetAllTeamFriendlyMatchesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="Nivdal_FriendlyGetAllTeamFriendlyMatches" SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>
    </ContentTemplate>    
    </asp:UpdatePanel>
    
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PageNamePlaceHolder" runat="Server">
    <asp:Label ID="PageNameLabel" runat="server" Text="<%$ Resources:Resource, Friendly_PageNameLabelText %>"
        CssClass="PageNameContentStyle"></asp:Label>
</asp:Content>
